package com.ruoyi.ic.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.constant.RConst;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ic.myutil.DocumentNum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ic.mapper.IcGeneralHMapper;
import com.ruoyi.ic.pojo.domain.IcGeneralH;
import com.ruoyi.ic.service.IIcGeneralHService;

/**
 * 出库单表头Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-25
 */
@Service
public class IcGeneralHServiceImpl implements IIcGeneralHService 
{
    @Autowired
    private IcGeneralHMapper icGeneralHMapper;
    @Autowired
    private DocumentNum documentNum;

    /**
     * 查询出库单表头
     * 
     * @param id 出库单表头主键
     * @return 出库单表头
     */
    @Override
    public IcGeneralH selectIcGeneralHById(Long id)
    {
        return icGeneralHMapper.selectIcGeneralHById(id);
    }

    /**
     * 查询出库单表头列表
     * 
     * @param icGeneralH 出库单表头
     * @return 出库单表头
     */
    @Override
    public List<IcGeneralH> selectIcGeneralHList(IcGeneralH icGeneralH)
    {
        return icGeneralHMapper.selectIcGeneralHList(icGeneralH);
    }

    /**
     * 新增出库单表头
     * 
     * @param icGeneralH 出库单表头
     * @return 结果
     */
    @Override
    public int insertIcGeneralH(IcGeneralH icGeneralH)
    {
        Date date = new Date();
        icGeneralH.setCreateTime(date);
        icGeneralH.setDel(RConst.Num.INT_0);
        icGeneralH.setVbillcode(documentNum.getVbillcode(date));
        icGeneralH.setDbizdate(date);
        icGeneralH.setCreater(SecurityUtils.getUsername().toString());
        return icGeneralHMapper.insertIcGeneralH(icGeneralH);
    }

    /**
     * 修改出库单表头
     * 
     * @param icGeneralH 出库单表头
     * @return 结果
     */
    @Override
    public int updateIcGeneralH(IcGeneralH icGeneralH)
    {
        icGeneralH.setUpdater(SecurityUtils.getUsername().toString());
        icGeneralH.setUpdateTime(new Date());
        return icGeneralHMapper.updateIcGeneralH(icGeneralH);
    }

    /**
     * 批量删除出库单表头
     * 
     * @param ids 需要删除的出库单表头主键
     * @return 结果
     */
    @Override
    public int deleteIcGeneralHByIds(Long[] ids)
    {
        return icGeneralHMapper.deleteIcGeneralHByIds(ids);
    }

    /**
     * 删除出库单表头信息
     * 
     * @param id 出库单表头主键
     * @return 结果
     */
    @Override
    public int deleteIcGeneralHById(Long id)
    {
        return icGeneralHMapper.deleteIcGeneralHById(id);
    }
}
